import { defineStore } from "pinia";
import { api } from "@/api";

export const useCategoriserStore = defineStore({
  id: "categoriser",
  state: () => ({
    categories: [] as Array<any>,
  }),
  getters: {
    navCat(state) {
      return state.categories.map((i) => ({
        label: i.Name,
        key: i.ID,
      }));
    },
  },
  actions: {
    async getCategories() {
      const res = (await api.get("categories")).data;
      this.categories = res.data;
    },
  },
});
